home *** CD-ROM | disk | FTP | other *** search
/ BMUG Newsletter 1996 Spring / S96 NL CD.iso / New NL PD Collections / Sound Manager 3.1 / For Programmers / Interfaces / Sound.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-08-24  |  22.2 KB  |  654 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Sound.h
  3.  
  4.      Contains:    Sound Manager Interfaces.
  5.  
  6.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  7.                  All rights reserved.
  8.  
  9.      Bugs:        Report bugs to Radar component “System Interfaces”, “Latest”
  10.  
  11. */
  12.  
  13. #ifndef __SOUND__
  14. #define __SOUND__
  15.  
  16.  
  17. #ifndef __TYPES__
  18. #include <Types.h>
  19. #endif
  20. /*    #include <ConditionalMacros.h>                                */
  21.  
  22. #ifndef __COMPONENTS__
  23. #include <Components.h>
  24. #endif
  25. /*    #include <MixedMode.h>                                        */
  26.  
  27. #ifndef __MIXEDMODE__
  28. #include <MixedMode.h>
  29. #endif
  30.  
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34.  
  35. #if PRAGMA_ALIGN_SUPPORTED
  36. #pragma options align=mac68k
  37. #endif
  38.  
  39. #if PRAGMA_IMPORT_SUPPORTED
  40. #pragma import on
  41. #endif
  42.  
  43.  
  44.  
  45. /*
  46.                         * * *  N O T E  * * *
  47.  
  48.     This file has been updated to include Sound Manager 3.1 interfaces.
  49.  
  50.     Some of the Sound Manager 3.0 interfaces were not put into the InterfaceLib
  51.     that originally shipped with the PowerMacs. These missing functions and the
  52.     new 3.1 interfaces have been released in the SoundLib library for PowerPC
  53.     developers to link with. The runtime library for these functions are
  54.     installed by Sound Manager 3.1. The following functions are found in SoundLib.
  55.  
  56.         GetCompressionInfo, GetSoundPreference, SetSoundPreference,
  57.         UnsignedFixedMulDiv, SndGetInfo, SndSetInfo
  58. */
  59. /*
  60.     Interfaces for Sound Driver, !!! OBSOLETE and NOT SUPPORTED !!!
  61.  
  62.     These items are no longer defined, but appear here so that someone
  63.     searching the interfaces might find them. If you are using one of these
  64.     items, you must change your code to support the Sound Manager.
  65.  
  66.         swMode, ftMode, ffMode
  67.         FreeWave, FFSynthRec, Tone, SWSynthRec, Wave, FTSoundRec
  68.         SndCompletionProcPtr
  69.         StartSound, StopSound, SoundDone
  70. */
  71.  
  72.  
  73. #define twelfthRootTwo            1.05946309434
  74. enum {
  75.     soundListRsrc                = 'snd ',                        /*Resource type used by Sound Manager*/
  76.     rate44khz                    = 0xAC440000L,                    /*44100.00000 in fixed-point*/
  77.     rate22050hz                    = 0x56220000L,                    /*22050.00000 in fixed-point*/
  78.     rate22khz                    = 0x56EE8BA3L,                    /*22254.54545 in fixed-point*/
  79.     rate11khz                    = 0x2B7745D1L,                    /*11127.27273 in fixed-point*/
  80.     rate11025hz                    = 0x2B110000,                    /*11025.00000 in fixed-point*/
  81. /*synthesizer numbers for SndNewChannel*/
  82.     squareWaveSynth                = 1,                            /*square wave synthesizer*/
  83.     waveTableSynth                = 3,                            /*wave table synthesizer*/
  84.     sampledSynth                = 5,                            /*sampled sound synthesizer*/
  85. /*old Sound Manager MACE synthesizer numbers*/
  86.     MACE3snthID                    = 11,
  87.     MACE6snthID                    = 13,
  88.     kMiddleC                    = 60,                            /*MIDI note value for middle C*/
  89.     kSimpleBeepID                = 1,                            /*reserved resource ID for Simple Beep*/
  90.     kFullVolume                    = 0x0100,                        /*1.0, setting for full hardware output volume*/
  91.     kNoVolume                    = 0,                            /*setting for no sound volume*/
  92. /*command numbers for SndDoCommand and SndDoImmediate*/
  93.     nullCmd                        = 0,
  94.     initCmd                        = 1,
  95.     freeCmd                        = 2,
  96.     quietCmd                    = 3,
  97.     flushCmd                    = 4,
  98.     reInitCmd                    = 5,
  99.     waitCmd                        = 10,
  100.     pauseCmd                    = 11,
  101.     resumeCmd                    = 12,
  102.     callBackCmd                    = 13
  103. };
  104.  
  105. enum {
  106.     syncCmd                        = 14,
  107.     availableCmd                = 24,
  108.     versionCmd                    = 25,
  109.     totalLoadCmd                = 26,
  110.     loadCmd                        = 27,
  111.     freqDurationCmd                = 40,
  112.     restCmd                        = 41,
  113.     freqCmd                        = 42,
  114.     ampCmd                        = 43,
  115.     timbreCmd                    = 44,
  116.     getAmpCmd                    = 45,
  117.     volumeCmd                    = 46,                            /*sound manager 3.0 or later only*/
  118.     getVolumeCmd                = 47,                            /*sound manager 3.0 or later only*/
  119.     waveTableCmd                = 60,
  120.     phaseCmd                    = 61
  121. };
  122.  
  123. enum {
  124.     soundCmd                    = 80,
  125.     bufferCmd                    = 81,
  126.     rateCmd                        = 82,
  127.     continueCmd                    = 83,
  128.     doubleBufferCmd                = 84,
  129.     getRateCmd                    = 85,
  130.     rateMultiplierCmd            = 86,
  131.     getRateMultiplierCmd        = 87,
  132.     sizeCmd                        = 90,
  133.     convertCmd                    = 91,
  134.     stdQLength                    = 128,
  135.     dataOffsetFlag                = 0x8000
  136. };
  137.  
  138. /*channel initialization parameters*/
  139. #if OLDROUTINENAMES
  140. enum {
  141.     waveInitChannelMask            = 0x07,
  142.     waveInitChannel0            = 0x04,                            /*wave table only, Sound Manager 2.0 and earlier*/
  143.     waveInitChannel1            = 0x05,                            /*wave table only, Sound Manager 2.0 and earlier*/
  144.     waveInitChannel2            = 0x06,                            /*wave table only, Sound Manager 2.0 and earlier*/
  145.     waveInitChannel3            = 0x07,                            /*wave table only, Sound Manager 2.0 and earlier*/
  146.     initChan0                    = waveInitChannel0,                /*obsolete spelling*/
  147.     initChan1                    = waveInitChannel1,                /*obsolete spelling*/
  148.     initChan2                    = waveInitChannel2,                /*obsolete spelling*/
  149.     initChan3                    = waveInitChannel3                /*obsolete spelling*/
  150. };
  151.  
  152. #endif
  153. enum {
  154.     initChanLeft                = 0x0002,                        /*left stereo channel*/
  155.     initChanRight                = 0x0003,                        /*right stereo channel*/
  156.     initNoInterp                = 0x0004,                        /*no linear interpolation*/
  157.     initNoDrop                    = 0x0008,                        /*no drop-sample conversion*/
  158.     initMono                    = 0x0080,                        /*monophonic channel*/
  159.     initStereo                    = 0x00C0,                        /*stereo channel*/
  160.     initMACE3                    = 0x0300,                        /*MACE 3:1*/
  161.     initMACE6                    = 0x0400,                        /*MACE 6:1*/
  162.     initPanMask                    = 0x0003,                        /*mask for right/left pan values*/
  163.     initSRateMask                = 0x0030,                        /*mask for sample rate values*/
  164.     initStereoMask                = 0x00C0,                        /*mask for mono/stereo values*/
  165.     initCompMask                = 0xFF00,                        /*mask for compression IDs*/
  166.     kUseOptionalOutputDevice    = -1,                            /*only for Sound Manager 3.0 or later*/
  167.     notCompressed                = 0,                            /*compression ID's*/
  168.     fixedCompression            = -1,                            /*compression ID for fixed-sized compression*/
  169.     variableCompression            = -2,                            /*compression ID for variable-sized compression*/
  170.     twoToOne                    = 1,
  171.     eightToThree                = 2,
  172.     threeToOne                    = 3,
  173.     sixToOne                    = 4
  174. };
  175.  
  176. enum {
  177.     stdSH                        = 0x00,                            /*Standard sound header encode value*/
  178.     extSH                        = 0xFF,                            /*Extended sound header encode value*/
  179.     cmpSH                        = 0xFE                            /*Compressed sound header encode value*/
  180. };
  181.  
  182. enum {
  183.     outsideCmpSH                = 0,                            /*MACE constants*/
  184.     insideCmpSH                    = 1,
  185.     aceSuccess                    = 0,
  186.     aceMemFull                    = 1,
  187.     aceNilBlock                    = 2,
  188.     aceBadComp                    = 3,
  189.     aceBadEncode                = 4,
  190.     aceBadDest                    = 5,
  191.     aceBadCmd                    = 6,
  192.     sixToOnePacketSize            = 8,
  193.     threeToOnePacketSize        = 16,
  194.     stateBlockSize                = 64,
  195.     leftOverBlockSize            = 32,
  196.     firstSoundFormat            = 0x0001,                        /*general sound format*/
  197.     secondSoundFormat            = 0x0002,                        /*special sampled sound format (HyperCard)*/
  198.     dbBufferReady                = 0x00000001,                    /*double buffer is filled*/
  199.     dbLastBuffer                = 0x00000004,                    /*last double buffer to play*/
  200.     sysBeepDisable                = 0x0000,                        /*SysBeep() enable flags*/
  201.     sysBeepEnable                = (1 << 0),
  202.     sysBeepSynchronous            = (1 << 1),                        /*if bit set, make alert sounds synchronous*/
  203.     unitTypeNoSelection            = 0xFFFF,                        /*unitTypes for AudioSelection.unitType*/
  204.     unitTypeSeconds                = 0x0000
  205. };
  206.  
  207.  
  208.  
  209. /* unsigned fixed-point number */
  210. typedef unsigned long UnsignedFixed;
  211.  
  212. struct SndCommand {
  213.     unsigned short                    cmd;
  214.     short                            param1;
  215.     long                            param2;
  216. };
  217. typedef struct SndCommand SndCommand;
  218.  
  219. typedef struct SndChannel SndChannel;
  220.  
  221. typedef SndChannel *SndChannelPtr;
  222.  
  223. typedef pascal void (*SndCallBackProcPtr)(SndChannelPtr chan, SndCommand *cmd);
  224.  
  225. #if GENERATINGCFM
  226. typedef UniversalProcPtr SndCallBackUPP;
  227. #else
  228. typedef SndCallBackProcPtr SndCallBackUPP;
  229. #endif
  230.  
  231. struct SndChannel {
  232.     struct SndChannel                *nextChan;
  233.     Ptr                                firstMod;                    /* reserved for the Sound Manager */
  234.     SndCallBackUPP                    callBack;
  235.     long                            userInfo;
  236.     long                            wait;                        /* The following is for internal Sound Manager use only.*/
  237.     SndCommand                        cmdInProgress;
  238.     short                            flags;
  239.     short                            qLength;
  240.     short                            qHead;
  241.     short                            qTail;
  242.     SndCommand                        queue[stdQLength];
  243. };
  244.  
  245.  
  246. /*MACE structures*/
  247. struct StateBlock {
  248.     short                            stateVar[stateBlockSize];
  249. };
  250. typedef struct StateBlock StateBlock;
  251.  
  252. typedef StateBlock *StateBlockPtr;
  253.  
  254. struct LeftOverBlock {
  255.     unsigned long                    count;
  256.     char                            sampleArea[leftOverBlockSize];
  257. };
  258. typedef struct LeftOverBlock LeftOverBlock;
  259.  
  260. typedef LeftOverBlock *LeftOverBlockPtr;
  261.  
  262. struct ModRef {
  263.     unsigned short                    modNumber;
  264.     long                            modInit;
  265. };
  266. typedef struct ModRef ModRef;
  267.  
  268. struct SndListResource {
  269.     short                            format;
  270.     short                            numModifiers;
  271.     ModRef                            modifierPart[1];            /*This is a variable length array*/
  272.     short                            numCommands;
  273.     SndCommand                        commandPart[1];                /*This is a variable length array*/
  274.     char                            dataPart[1];                /*This is a variable length array*/
  275. };
  276. typedef struct SndListResource SndListResource;
  277.  
  278. typedef SndListResource *SndListPtr;
  279.  
  280. typedef SndListPtr *SndListHndl, *SndListHandle;
  281.  
  282. /*HyperCard sound resource format*/
  283. struct Snd2ListResource {
  284.     short                            format;
  285.     short                            refCount;
  286.     short                            numCommands;
  287.     SndCommand                        commandPart[1];                /*This is a variable length array*/
  288.     char                            dataPart[1];                /*This is a variable length array*/
  289. };
  290. typedef struct Snd2ListResource Snd2ListResource;
  291.  
  292. typedef Snd2ListResource *Snd2ListPtr;
  293.  
  294. typedef Snd2ListPtr *Snd2ListHndl, *Snd2ListHandle;
  295.  
  296. struct SoundHeader {
  297.     Ptr                                samplePtr;                    /*if NIL then samples are in sampleArea*/
  298.     unsigned long                    length;                        /*length of sound in bytes*/
  299.     UnsignedFixed                    sampleRate;                    /*sample rate for this sound*/
  300.     unsigned long                    loopStart;                    /*start of looping portion*/
  301.     unsigned long                    loopEnd;                    /*end of looping portion*/
  302.     unsigned char                    encode;                        /*header encoding*/
  303.     unsigned char                    baseFrequency;                /*baseFrequency value*/
  304.     unsigned char                    sampleArea[1];                /*space for when samples follow directly*/
  305. };
  306. typedef struct SoundHeader SoundHeader;
  307.  
  308. typedef SoundHeader *SoundHeaderPtr;
  309.  
  310. struct CmpSoundHeader {
  311.     Ptr                                samplePtr;                    /*if nil then samples are in sample area*/
  312.     unsigned long                    numChannels;                /*number of channels i.e. mono = 1*/
  313.     UnsignedFixed                    sampleRate;                    /*sample rate in Apples Fixed point representation*/
  314.     unsigned long                    loopStart;                    /*loopStart of sound before compression*/
  315.     unsigned long                    loopEnd;                    /*loopEnd of sound before compression*/
  316.     unsigned char                    encode;                        /*data structure used , stdSH, extSH, or cmpSH*/
  317.     unsigned char                    baseFrequency;                /*same meaning as regular SoundHeader*/
  318.     unsigned long                    numFrames;                    /*length in frames ( packetFrames or sampleFrames )*/
  319.     extended80                        AIFFSampleRate;                /*IEEE sample rate*/
  320.     Ptr                                markerChunk;                /*sync track*/
  321.     OSType                            format;                        /*data format type, was futureUse1*/
  322.     unsigned long                    futureUse2;                    /*reserved by Apple*/
  323.     StateBlockPtr                    stateVars;                    /*pointer to State Block*/
  324.     LeftOverBlockPtr                leftOverSamples;            /*used to save truncated samples between compression calls*/
  325.     short                            compressionID;                /*0 means no compression, non zero means compressionID*/
  326.     unsigned short                    packetSize;                    /*number of bits in compressed sample packet*/
  327.     unsigned short                    snthID;                        /*resource ID of Sound Manager snth that contains NRT C/E*/
  328.     unsigned short                    sampleSize;                    /*number of bits in non-compressed sample*/
  329.     unsigned char                    sampleArea[1];                /*space for when samples follow directly*/
  330. };
  331. typedef struct CmpSoundHeader CmpSoundHeader;
  332.  
  333. typedef CmpSoundHeader *CmpSoundHeaderPtr;
  334.  
  335. struct ExtSoundHeader {
  336.     Ptr                                samplePtr;                    /*if nil then samples are in sample area*/
  337.     unsigned long                    numChannels;                /*number of channels,  ie mono = 1*/
  338.     UnsignedFixed                    sampleRate;                    /*sample rate in Apples Fixed point representation*/
  339.     unsigned long                    loopStart;                    /*same meaning as regular SoundHeader*/
  340.     unsigned long                    loopEnd;                    /*same meaning as regular SoundHeader*/
  341.     unsigned char                    encode;                        /*data structure used , stdSH, extSH, or cmpSH*/
  342.     unsigned char                    baseFrequency;                /*same meaning as regular SoundHeader*/
  343.     unsigned long                    numFrames;                    /*length in total number of frames*/
  344.     extended80                        AIFFSampleRate;                /*IEEE sample rate*/
  345.     Ptr                                markerChunk;                /*sync track*/
  346.     Ptr                                instrumentChunks;            /*AIFF instrument chunks*/
  347.     Ptr                                AESRecording;
  348.     unsigned short                    sampleSize;                    /*number of bits in sample*/
  349.     unsigned short                    futureUse1;                    /*reserved by Apple*/
  350.     unsigned long                    futureUse2;                    /*reserved by Apple*/
  351.     unsigned long                    futureUse3;                    /*reserved by Apple*/
  352.     unsigned long                    futureUse4;                    /*reserved by Apple*/
  353.     unsigned char                    sampleArea[1];                /*space for when samples follow directly*/
  354. };
  355. typedef struct ExtSoundHeader ExtSoundHeader;
  356.  
  357. typedef ExtSoundHeader *ExtSoundHeaderPtr;
  358.  
  359. struct ConversionBlock {
  360.     short                            destination;
  361.     short                            unused;
  362.     CmpSoundHeaderPtr                inputPtr;
  363.     CmpSoundHeaderPtr                outputPtr;
  364. };
  365. typedef struct ConversionBlock ConversionBlock;
  366.  
  367. typedef ConversionBlock *ConversionBlockPtr;
  368.  
  369. struct SMStatus {
  370.     short                            smMaxCPULoad;
  371.     short                            smNumChannels;
  372.     short                            smCurCPULoad;
  373. };
  374. typedef struct SMStatus SMStatus;
  375.  
  376. typedef SMStatus *SMStatusPtr;
  377.  
  378. struct SCStatus {
  379.     UnsignedFixed                    scStartTime;
  380.     UnsignedFixed                    scEndTime;
  381.     UnsignedFixed                    scCurrentTime;
  382.     Boolean                            scChannelBusy;
  383.     Boolean                            scChannelDisposed;
  384.     Boolean                            scChannelPaused;
  385.     Boolean                            scUnused;
  386.     unsigned long                    scChannelAttributes;
  387.     long                            scCPULoad;
  388. };
  389. typedef struct SCStatus SCStatus;
  390.  
  391. typedef SCStatus *SCStatusPtr;
  392.  
  393. struct AudioSelection {
  394.     long                            unitType;
  395.     UnsignedFixed                    selStart;
  396.     UnsignedFixed                    selEnd;
  397. };
  398. typedef pascal void (*FilePlayCompletionProcPtr)(SndChannelPtr chan);
  399.  
  400. #if GENERATINGCFM
  401. typedef UniversalProcPtr FilePlayCompletionUPP;
  402. #else
  403. typedef FilePlayCompletionProcPtr FilePlayCompletionUPP;
  404. #endif
  405.  
  406. enum {
  407.     uppFilePlayCompletionProcInfo = kPascalStackBased
  408.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SndChannelPtr)))
  409. };
  410.  
  411. #if GENERATINGCFM
  412. #define NewFilePlayCompletionProc(userRoutine)        \
  413.         (FilePlayCompletionUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppFilePlayCompletionProcInfo, GetCurrentArchitecture())
  414. #else
  415. #define NewFilePlayCompletionProc(userRoutine)        \
  416.         ((FilePlayCompletionUPP) (userRoutine))
  417. #endif
  418.  
  419. #if GENERATINGCFM
  420. #define CallFilePlayCompletionProc(userRoutine, chan)        \
  421.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppFilePlayCompletionProcInfo, (chan))
  422. #else
  423. #define CallFilePlayCompletionProc(userRoutine, chan)        \
  424.         (*(userRoutine))((chan))
  425. #endif
  426.  
  427. typedef struct AudioSelection AudioSelection;
  428.  
  429. typedef AudioSelection *AudioSelectionPtr;
  430.  
  431. struct SndDoubleBuffer {
  432.     long                            dbNumFrames;
  433.     long                            dbFlags;
  434.     long                            dbUserInfo[2];
  435.     char                            dbSoundData[1];
  436. };
  437. typedef struct SndDoubleBuffer SndDoubleBuffer;
  438.  
  439. typedef SndDoubleBuffer *SndDoubleBufferPtr;
  440.  
  441. typedef pascal void (*SndDoubleBackProcPtr)(SndChannelPtr channel, SndDoubleBufferPtr doubleBufferPtr);
  442.  
  443. #if GENERATINGCFM
  444. typedef UniversalProcPtr SndDoubleBackUPP;
  445. #else
  446. typedef SndDoubleBackProcPtr SndDoubleBackUPP;
  447. #endif
  448.  
  449. enum {
  450.     uppSndDoubleBackProcInfo = kPascalStackBased
  451.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SndChannelPtr)))
  452.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(SndDoubleBufferPtr)))
  453. };
  454.  
  455. #if GENERATINGCFM
  456. #define NewSndDoubleBackProc(userRoutine)        \
  457.         (SndDoubleBackUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSndDoubleBackProcInfo, GetCurrentArchitecture())
  458. #else
  459. #define NewSndDoubleBackProc(userRoutine)        \
  460.         ((SndDoubleBackUPP) (userRoutine))
  461. #endif
  462.  
  463. #if GENERATINGCFM
  464. #define CallSndDoubleBackProc(userRoutine, channel, doubleBufferPtr)        \
  465.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSndDoubleBackProcInfo, (channel), (doubleBufferPtr))
  466. #else
  467. #define CallSndDoubleBackProc(userRoutine, channel, doubleBufferPtr)        \
  468.         (*(userRoutine))((channel), (doubleBufferPtr))
  469. #endif
  470.  
  471. struct SndDoubleBufferHeader {
  472.     short                            dbhNumChannels;
  473.     short                            dbhSampleSize;
  474.     short                            dbhCompressionID;
  475.     short                            dbhPacketSize;
  476.     UnsignedFixed                    dbhSampleRate;
  477.     SndDoubleBufferPtr                dbhBufferPtr[2];
  478.     SndDoubleBackUPP                dbhDoubleBack;
  479. };
  480. typedef struct SndDoubleBufferHeader SndDoubleBufferHeader;
  481.  
  482. typedef SndDoubleBufferHeader *SndDoubleBufferHeaderPtr;
  483.  
  484. struct SndDoubleBufferHeader2 {
  485.     short                            dbhNumChannels;
  486.     short                            dbhSampleSize;
  487.     short                            dbhCompressionID;
  488.     short                            dbhPacketSize;
  489.     UnsignedFixed                    dbhSampleRate;
  490.     SndDoubleBufferPtr                dbhBufferPtr[2];
  491.     SndDoubleBackUPP                dbhDoubleBack;
  492.     OSType                            dbhFormat;
  493. };
  494. typedef struct SndDoubleBufferHeader2 SndDoubleBufferHeader2;
  495.  
  496. typedef SndDoubleBufferHeader2 *SndDoubleBufferHeader2Ptr;
  497.  
  498. struct SoundInfoList {
  499.     short                            count;
  500.     Handle                            infoHandle;
  501. };
  502. typedef struct SoundInfoList SoundInfoList;
  503.  
  504. typedef SoundInfoList *SoundInfoListPtr;
  505.  
  506. struct CompressionInfo {
  507.     long                            recordSize;
  508.     OSType                            format;
  509.     short                            compressionID;
  510.     unsigned short                    samplesPerPacket;
  511.     unsigned short                    bytesPerPacket;
  512.     unsigned short                    bytesPerFrame;
  513.     unsigned short                    bytesPerSample;
  514.     unsigned short                    futureUse1;
  515. };
  516. typedef struct CompressionInfo CompressionInfo;
  517.  
  518. typedef CompressionInfo *CompressionInfoPtr;
  519.  
  520. typedef CompressionInfoPtr *CompressionInfoHandle;
  521.  
  522. /* These two routines for Get/SetSoundVol should no longer be used.*/
  523. /* They were for old Apple Sound Chip machines, and do not support the DSP or PowerMacs.*/
  524. /* Use Get/SetDefaultOutputVolume instead, if you must change the user's machine.*/
  525. #if OLDROUTINENAMES && !GENERATINGCFM
  526. extern pascal void SetSoundVol(short level);
  527.  
  528. #if !GENERATINGCFM
  529. #pragma parameter GetSoundVol(__A0)
  530. #endif
  531. extern pascal void GetSoundVol(short *level)
  532.  THREEWORDINLINE(0x4218, 0x10B8, 0x0260);
  533. #endif
  534.  
  535.  
  536. extern pascal OSErr SndDoCommand(SndChannelPtr chan, const SndCommand *cmd, Boolean noWait)
  537.  ONEWORDINLINE(0xA803);
  538. extern pascal OSErr SndDoImmediate(SndChannelPtr chan, const SndCommand *cmd)
  539.  ONEWORDINLINE(0xA804);
  540. extern pascal OSErr SndNewChannel(SndChannelPtr *chan, short synth, long init, SndCallBackUPP userRoutine)
  541.  ONEWORDINLINE(0xA807);
  542. extern pascal OSErr SndDisposeChannel(SndChannelPtr chan, Boolean quietNow)
  543.  ONEWORDINLINE(0xA801);
  544. extern pascal OSErr SndPlay(SndChannelPtr chan, SndListHandle sndHdl, Boolean async)
  545.  ONEWORDINLINE(0xA805);
  546. #if OLDROUTINENAMES
  547. extern pascal OSErr SndAddModifier(SndChannelPtr chan, Ptr modifier, short id, long init)
  548.  ONEWORDINLINE(0xA802);
  549. #endif
  550. extern pascal OSErr SndControl(short id, SndCommand *cmd)
  551.  ONEWORDINLINE(0xA806);
  552.  
  553.  
  554. /* Sound Manager 2.0 and later, uses _SoundDispatch */
  555. /* SndSoundManagerVersion() returns a NumVersion*/
  556. extern pascal unsigned long SndSoundManagerVersion(void)
  557.  FOURWORDINLINE(0x203C, 0x000C, 0x0008, 0xA800);
  558. extern pascal OSErr SndStartFilePlay(SndChannelPtr chan, short fRefNum, short resNum, long bufferSize, void *theBuffer, AudioSelectionPtr theSelection, FilePlayCompletionUPP theCompletion, Boolean async)
  559.  FOURWORDINLINE(0x203C, 0x0D00, 0x0008, 0xA800);
  560. extern pascal OSErr SndPauseFilePlay(SndChannelPtr chan)
  561.  FOURWORDINLINE(0x203C, 0x0204, 0x0008, 0xA800);
  562. extern pascal OSErr SndStopFilePlay(SndChannelPtr chan, Boolean quietNow)
  563.  FOURWORDINLINE(0x203C, 0x0308, 0x0008, 0xA800);
  564. extern pascal OSErr SndChannelStatus(SndChannelPtr chan, short theLength, SCStatusPtr theStatus)
  565.  FOURWORDINLINE(0x203C, 0x0510, 0x0008, 0xA800);
  566. extern pascal OSErr SndManagerStatus(short theLength, SMStatusPtr theStatus)
  567.  FOURWORDINLINE(0x203C, 0x0314, 0x0008, 0xA800);
  568. extern pascal void SndGetSysBeepState(short *sysBeepState)
  569.  FOURWORDINLINE(0x203C, 0x0218, 0x0008, 0xA800);
  570. extern pascal OSErr SndSetSysBeepState(short sysBeepState)
  571.  FOURWORDINLINE(0x203C, 0x011C, 0x0008, 0xA800);
  572. extern pascal OSErr SndPlayDoubleBuffer(SndChannelPtr chan, SndDoubleBufferHeaderPtr theParams)
  573.  FOURWORDINLINE(0x203C, 0x0420, 0x0008, 0xA800);
  574.  
  575.  
  576. /* MACE compression routines */
  577. /* MACEVersion() returns a NumVersion*/
  578. extern pascal unsigned long MACEVersion(void)
  579.  FOURWORDINLINE(0x203C, 0x0000, 0x0010, 0xA800);
  580. extern pascal void Comp3to1(const void *inBuffer, void *outBuffer, unsigned long cnt, StateBlockPtr inState, StateBlockPtr outState, unsigned long numChannels, unsigned long whichChannel)
  581.  FOURWORDINLINE(0x203C, 0x0004, 0x0010, 0xA800);
  582. extern pascal void Exp1to3(const void *inBuffer, void *outBuffer, unsigned long cnt, StateBlockPtr inState, StateBlockPtr outState, unsigned long numChannels, unsigned long whichChannel)
  583.  FOURWORDINLINE(0x203C, 0x0008, 0x0010, 0xA800);
  584. extern pascal void Comp6to1(const void *inBuffer, void *outBuffer, unsigned long cnt, StateBlockPtr inState, StateBlockPtr outState, unsigned long numChannels, unsigned long whichChannel)
  585.  FOURWORDINLINE(0x203C, 0x000C, 0x0010, 0xA800);
  586. extern pascal void Exp1to6(const void *inBuffer, void *outBuffer, unsigned long cnt, StateBlockPtr inState, StateBlockPtr outState, unsigned long numChannels, unsigned long whichChannel)
  587.  FOURWORDINLINE(0x203C, 0x0010, 0x0010, 0xA800);
  588.  
  589.  
  590. /* Sound Manager 3.0 and later calls */
  591. extern pascal OSErr GetSysBeepVolume(long *level)
  592.  FOURWORDINLINE(0x203C, 0x0224, 0x0018, 0xA800);
  593. extern pascal OSErr SetSysBeepVolume(long level)
  594.  FOURWORDINLINE(0x203C, 0x0228, 0x0018, 0xA800);
  595. extern pascal OSErr GetDefaultOutputVolume(long *level)
  596.  FOURWORDINLINE(0x203C, 0x022C, 0x0018, 0xA800);
  597. extern pascal OSErr SetDefaultOutputVolume(long level)
  598.  FOURWORDINLINE(0x203C, 0x0230, 0x0018, 0xA800);
  599. extern pascal OSErr GetSoundHeaderOffset(SndListHandle sndHandle, long *offset)
  600.  FOURWORDINLINE(0x203C, 0x0404, 0x0018, 0xA800);
  601. extern pascal UnsignedFixed UnsignedFixedMulDiv(UnsignedFixed value, UnsignedFixed multiplier, UnsignedFixed divisor)
  602.  FOURWORDINLINE(0x203C, 0x060C, 0x0018, 0xA800);
  603. extern pascal OSErr GetCompressionInfo(short compressionID, OSType format, short numChannels, short sampleSize, CompressionInfoPtr cp)
  604.  FOURWORDINLINE(0x203C, 0x0710, 0x0018, 0xA800);
  605. extern pascal OSErr SetSoundPreference(OSType theType, Str255 name, Handle settings)
  606.  FOURWORDINLINE(0x203C, 0x0634, 0x0018, 0xA800);
  607. extern pascal OSErr GetSoundPreference(OSType theType, Str255 name, Handle settings)
  608.  FOURWORDINLINE(0x203C, 0x0638, 0x0018, 0xA800);
  609.  
  610.  
  611. /* Sound Manager 3.1 and later calls */
  612. extern pascal OSErr SndGetInfo(SndChannelPtr chan, OSType selector, void *infoPtr)
  613.  FOURWORDINLINE(0x203C, 0x063C, 0x0018, 0xA800);
  614. extern pascal OSErr SndSetInfo(SndChannelPtr chan, OSType selector, void *infoPtr)
  615.  FOURWORDINLINE(0x203C, 0x0640, 0x0018, 0xA800);
  616.  
  617.  
  618. enum {
  619.     uppSndCallBackProcInfo = kPascalStackBased
  620.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SndChannelPtr)))
  621.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(SndCommand*)))
  622. };
  623.  
  624. #if GENERATINGCFM
  625. #define NewSndCallBackProc(userRoutine)        \
  626.         (SndCallBackUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSndCallBackProcInfo, GetCurrentArchitecture())
  627. #else
  628. #define NewSndCallBackProc(userRoutine)        \
  629.         ((SndCallBackUPP) (userRoutine))
  630. #endif
  631.  
  632. #if GENERATINGCFM
  633. #define CallSndCallBackProc(userRoutine, chan, cmd)        \
  634.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppSndCallBackProcInfo, (chan), (cmd))
  635. #else
  636. #define CallSndCallBackProc(userRoutine, chan, cmd)        \
  637.         (*(userRoutine))((chan), (cmd))
  638. #endif
  639.  
  640.  
  641. #if PRAGMA_IMPORT_SUPPORTED
  642. #pragma import off
  643. #endif
  644.  
  645. #if PRAGMA_ALIGN_SUPPORTED
  646. #pragma options align=reset
  647. #endif
  648.  
  649. #ifdef __cplusplus
  650. }
  651. #endif
  652.  
  653. #endif /* __SOUND__ */
  654.